<table id="deptTable" style="height:100%" data-options="">
</table>
<div id="tb" >
	<% if(authUrl("/departmentUser/toAddUser")){ %>
	<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="addUser()">添加用户</a>
	<% } %>
	<% if(authUrl("/departmentUser/toUpUser")){ %>
	<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-edit',plain:true" onclick="editUser()">修改用户</a>
	<% } %>
</div>
<script>
	
	var curDeptIds = "${curUserDept.ids}";
	var curDeptName = "${curUserDept.name}";
	function lookInfo(ids){
		loadViewDialog('查看信息', 'organization/lookUserInfo?ids=' + ids);
	}
	function addUser(){
		var deptTree = $.fn.zTree.getZTreeObj("deptTree");
		var nodes = deptTree.getSelectedNodes();
		loadDialog($("#deptTable"), null, '添加用户', 'departmentUser/toAddUser?ids=' + nodes[0].id);
	}
	function editUser(){
		 var row = $("#deptTable").datagrid('getSelected');
		 if(row == null){
			 $.slideMsg("请选中一条记录！", parent.$);
		 }else{
			 loadDialog($("#deptTable"), null, '编辑用户', 'departmentUser/toUpUser?ids=' + row.ids);
		 }
	}
	
	function initDeptTable(curNode){
		$('#deptTable').datagrid({
			cls: "theme-datagrid",
			title: curNode.name,
			toolbar: '#tb',
			singleSelect: true,
			rownumbers: true, //显示序号
			pagination: true,
			pageSize: 20,
			url: "departmentUser/deptUserList",
			queryParams: {
				'_query.bh': curNode.bh + "%"
			},
		    method: 'post',
			collapsible: true,
			columns:[[
				  		{field:'ids',title:'ids',width:100,align:'center', hidden:true},
				  		//{field:'username',title:'用户名',width:100,align:'center'},
				  		{field:'name',title:'姓名',width:100, align:'center',
				  			formatter: function(value,row,index){
				  				var ids = row.ids;
								return '<a href="#" style="color: blue;" class="button-edit" onclick="lookInfo(\'' + ids + '\')">' + value + '</a>';
							}
				  		},
				  		//{field:'mobile',title:'联系方式',width:160, align:'center'},
				  		{field:'dname',title:'部门',width:100, align:'center'},
				  		{field:'stationname',title:'岗位',width:100, align:'center'},
				  		{field:'verificationcode',title:'验证码',width:100, align:'center'},
				  		{field:'status',title:'状态',width:100, align:'center',
				  			formatter: function(value,row,index){
				  				var status = row.status;
				  				if(status == 1){
				  					return '正常';
				  				}else{
				  					return '禁用';
				  				}
				  			}
				  		}
				      ]],
			onLoadSuccess:function(){
				
			}
		});
	}
</script>